﻿package{
	public class DSDatTien{
		var DanhSach:Array;

		public function DSDatTien(){
			DanhSach=new Array();
		}

		public function ThemDatTien(dt:DatTien):void{
			DanhSach.push(dt);
		}
		public function SoLanDat(dat:int, soTien:int):int{
			var tong:int=0;
			for each(var item in DanhSach){
				if(item.dat==dat&&item.soTien==soTien){
					tong=tong+1;
				}
			}
			return tong;
		}
		
		public function KiemTraLoaiTien(tien:int):Boolean{
			for each(var item in DanhSach){
				if(item.soTien==tien)
					return true;
			}
			return false;
		}
		public function XuatDT():void{
				for each(var item in DanhSach){
					item.Xuat();
				}
		}
		public function KiemTraThang(kq1:int, kq2:int, kq3:int, nguoiChoi:NguoiChoi):uint{
			var ten:String;
			for each(var item in DanhSach){
				ten=item.nguoiChoi.ten;
				if(ten==nguoiChoi.ten && item.dat==kq1){
					nguoiChoi.tien=nguoiChoi.tien + 2*item.soTien;
				}else if(ten==nguoiChoi.ten && item.dat==kq2){
					nguoiChoi.tien= nguoiChoi.tien + 2*item.soTien;
				}else if(ten==nguoiChoi.ten && item.dat==kq3){
					nguoiChoi.tien+= nguoiChoi.tien + 2*item.soTien;
				}
			}
			return nguoiChoi.tien;
		}
		
		public function SoLanNguoiChoiDat(ten:String):uint{
			var tong:int=0;
			for each(var item in DanhSach){
				if(item.nguoiChoi.ten==ten){
					tong=tong+1;
				}
			}
			return tong;
		
		}
	}	
}